package com.ssm.zyn.action;

import com.ssm.zyn.eo.ConlogEOpage;
import com.ssm.zyn.model.Conlog;
import com.ssm.zyn.service.Conlogservice;
import com.ssm.zyn.tool.ResponseMessage;
import com.ssm.zyn.tool.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 对外提供数据服务接口
 */
@Api(tags="Conlog")
@RestController
@CrossOrigin
public class ConlogController {
    @Autowired
    private Conlogservice conlogservice;
    @ApiOperation(value = "日志添加方法")
    @RequestMapping(value="/addConlog",method = RequestMethod.GET)
    public ResponseMessage addConlog(Conlog conlog){
        int IsAdd=0;
        //传入数据的判断
        //（1）实体对象不能为空
        if(conlog!=null){

                //(2)添加数据
                IsAdd=conlogservice.AddConlog(conlog);
                if(IsAdd==1){
                    return Result.success("保存成功");
                }else {
                    return Result.error("保存失败");
                }

        }
        return Result.error("保存失败");
    }
    @ApiOperation(value = "根据条件获取日志信息")
    @RequestMapping(value = "/getConlogAll",produces = "application/json;charset=utf-8",method = RequestMethod.POST)
    public ResponseMessage getConlogAll(/*@RequestBody*/ ConlogEOpage conlogEOpage){
        Map<String, List> map=new HashMap<>();
        List<ConlogEOpage> listConlogEO=conlogservice.getWhereAll(conlogEOpage);
        map.put("list",listConlogEO);
        return Result.success("200",map);
    }
}
